<?php


namespace app\api\validate;


use think\Validate;

class User extends Validate
{
    protected $rule = [
        'username' => 'require',
        'password' => 'require|alphaNum',
        'code' => 'require|number|min:4',
        'type' => 'require|in:1,2',
    ];

    protected $message = [
        'username' => '用户名不能为空',
        'password.require' => '密码不能为空',
        'password.alphaNum' => '密码只能为字母和数字',
        'code.require' => '验证码不能为空',
        'code.number' => '验证码必须为数字',
        'code.min' => '验证码长度不能小于4',
        'type.require' => '登录类型必须',
        'type.in' => '登录类型错误',
    ];

    protected $scene = [
        'login' => ['username', 'password'],
        'register' => ['username']
    ];

}
